setopt appendhistory     # Immediately append history instead of overwriting
setopt autocd            # if only directory path is entered, cd there.
setopt correct           # Auto correct mistakes
setopt extendedglob      # Extended globbing. Allows using regular expressions with *
setopt histignorealldups # If a new command is a duplicate, remove the older one
setopt nobeep            # No beep
setopt nocaseglob        # Case insensitive globbing
setopt nocheckjobs       # Don't warn about running processes when exiting
setopt numericglobsort   # Sort filenames numerically when it makes sense
setopt rcexpandparam     # Array expension with parameters

HISTFILE=$ZDOTDIR/.zsh_history
HISTSIZE=10000
SAVEHIST=10000
WORDCHARS=${WORDCHARS//\/[&.;]} # Don't consider certain characters part of the word

# Init CLI tools that need it
command -v zoxide > /dev/null 2>&1 && eval "$(zoxide init zsh)"
command -v fnm > /dev/null 2>&1 && eval "$(fnm env --use-on-cd)"
command -v fzf > /dev/null && source <(fzf --zsh)

source $ZDOTDIR/.zim.zsh
source $ZDOTDIR/.keybindings.zsh
source $ZDOTDIR/.aliases.zsh

# Enable loading custom functions
fpath=($ZDOTDIR/.zfunc $ZDOTDIR/.zcomp $fpath)
autoload -Uz $ZDOTDIR/.zfunc/*(:t)
autoload -Uz $ZDOTDIR/.zcomp/**/*(:t)
autoload -U zmv

# Source local overrides
[ -s $ZDOTDIR/.zprofile.local ] && source $ZDOTDIR/.zprofile.local
[ -s $ZDOTDIR/.zshrc.local ] && source $ZDOTDIR/.zshrc.local
[ -s $ZDOTDIR/.aliases.local ] && source $ZDOTDIR/.aliases.local
